package cn.pugle.base;

import java.io.IOException;
import java.util.*;

/**
 * Created by tzp on 15-12-23.<br/>
 */
public class Tips {


    public static void main(String[] args) throws IOException {
        try {
            tryFinal();
        } catch (Exception e) {
            System.out.println(e);
        }
    }

    public static void tryFinal() {
        try {
            System.out.println("1");
            throw new Exception("1");
        } catch (Exception e) {
            System.out.println("2");
            throw new RuntimeException("2");
        } finally {
            System.out.println("3");
        }
    }

    public static void integerEquals(String[] args) {
        Integer i1 = 1000001;
        Integer i2 = 1000001;
        System.out.println(i1 == i2);
        System.out.println(i1.equals(i2));
    }

    public static void splitList() {
        ArrayList<Integer> list = new ArrayList<Integer>() {{
            add(1);
            add(2);
            add(3);
        }};
        List<Integer> subList = list.subList(0, 1);//是原list的局部视图
        subList.add(4);
        System.out.println("hehe");
    }

    public void arraysShit() {
        int[] is = new int[]{1, 2};
        if (Arrays.asList(is).contains(1)) {
            System.out.println("its ok");
        }
//        if (Arrays.<Integer>asList(is).contains(1)){
//            System.out.println("that's ok");
//        }//编译不通过shit
    }

    public void splitShit() {
        System.out.println("1,,".split(",", -1).length);
    }

    public void singltonList() {
        Set<String> s = Collections.singleton("s");
    }

}
